package univer.oko.gui;

import univer.oko.DBWorker;
import univer.oko.payment.Payment;
import univer.oko.student.Student;
import univer.oko.table.CDTable;

import javax.swing.*;
import java.rmi.RemoteException;
import java.util.Vector;
import java.util.ArrayList;


public abstract class CDInternalFrame extends JInternalFrame {
    protected CDTable table;
    public static boolean isNeed2Update;
    protected Vector list;


    public CDInternalFrame() {
        super("", false, true, false, false);
    }

    public Student getStudent() {
        try {
            int index = table.getSelectedRow();
            if (index != -1 && list != null) {
                Student st = (Student) list.get(index);
                return DBWorker.instance().getStudent(st.getID());
            }
            return null;
        }
        catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    public Payment getPayment() {
        try {
            int index = table.getSelectedRow();
            if (index != -1 && list != null) {
                Payment p = (Payment) list.get(index);
                return DBWorker.instance().getPayment(p.getID());
            }
            return null;
        }
        catch (RemoteException e) {
            throw new RuntimeException(e);
        }
    }

    
}
